<?php echo $this->render('link/header.phtml') ?>
<?php $gridId=uniqid(); ?>
//常用变量初始化
var menuDelUrl=baseUrl+"/link/serversite/type/del";
var menuEditUrl=baseUrl+"/link/serversite/type/edit";
var module="site";
var gridTitle="自动执行设置";
var dataId="site_id";
Ext.form.Field.prototype.msgTarget = 'side';

var myCheck=[
				['0','手动执行'],
				 ['1','自动执行']
				 ];	
var autoCheck_store=new Ext.data.SimpleStore({
									   fields:[
											   {name:'id'},
											   {name:'name'},
									   		  ]
									   });
autoCheck_store.loadData(myCheck);
var autocheck_type=new Ext.form.ComboBox({
 										fieldLabel:'自动执行类型',
										store:autoCheck_store,										
        								displayField:'name',
        								valueField :'id',
										hiddenName:"autocheck_type",
        								typeAhead:true,
        								mode:'local',
        								triggerAction:'all',
                                        editable:false,  
        								selectOnFocus:true,
                                        emptyText:"请选择",
                                        allowBlank:false,
                                        value:'<?=$this->isautocheck?>'	
});
                                       

                                                                                
var link_add=new Ext.FormPanel({
	frame:true,
    title:gridTitle,
    labelWidth:100,
    autoWidht:true,
    autoHeight:true,    
    bodyStyle:'padding:0 0 0 0;',    
    items:[autocheck_type,
   		  { 
          id:'autocheck_time',
          name:'autocheck_time',
          xtype:'numberfield',
          fieldLabel:'选择间隔时间',
          value:'<?=$this->autochecktime?>'
           }
    ],
    buttons:[
    {
    id:'submit',
    text:'提交',
    type:'submit',
    iconCls:'icn-control',
    handler:function(){
    if(link_add.getForm().isValid()){
    //console.log(autocheck_type.getValue());
    //console.log(Ext.get('autocheck_time').getValue());
    if(autocheck_type.getValue()=='1' && Ext.get('autocheck_time').getValue()==""){
    Ext.MessageBox.alert("提示","请将数据填写完整");
    return;
    }
    link_add.getForm().submit({
    waitTitle:'提示',
    waitMsg:'请稍等',
    url:baseUrl+'/link/serverconfig/type/edit',
    success:function(form,action){
    	var _message=Ext.util.JSON.decode(action.response.responseText);
		Ext.MessageBox.alert('提示',_message.msg);
    },
    failure:function(form,action){
    	var _message=Ext.util.JSON.decode(action.response.responseText);
        Ext.MessageBox.alert('提示',_message.msg);
    }
    });
    }   
    }},{
    text:'退出',
    handler:function(){
    Ext.getCmp('content').getActiveTab().remove();
    }
    }
    ]
});

var auto_check=new Ext.FormPanel({
	frame:true,
    title:'审核设置',
    labelWidth:100,
    autoWidht:true,
    autoHeight:true,    
    bodyStyle:'padding:0 0 0 0;',    
	items:[{
          name:'is_autocheck',
          xtype:'checkbox',
          fieldLabel:'是否启用自动审核',
          checked:<?=(($this->is_autocheck=="on")?'true':'false')?>},{
          name:'expire_day',
          xtype:'numberfield',
          fieldLabel:'超期天数设置',
          allowBlank:false,
          value:'<?=$this->expireday?>'
          }],
    buttons:[{
    id:'submit',
    text:'提交',
    type:'submit',
    iconCls:'icn-control',
    handler:function(){
    	if(auto_check.getForm().isValid()){
        	 auto_check.getForm().submit({
    			waitTitle:'提示',
    			waitMsg:'请稍等',
    			url:baseUrl+'/link/serverconfig/type/expire_day',
    			success:function(form,action){
    				var _message=Ext.util.JSON.decode(action.response.responseText);
					Ext.MessageBox.alert('提示',_message.msg);
    			},
    			failure:function(form,action){
    				var _message=Ext.util.JSON.decode(action.response.responseText);
        			Ext.MessageBox.alert('提示',_message.msg);
    			}
    });
        }
    }
    },{
    text:'退出',
    handler:function(){
    Ext.getCmp('content').getActiveTab().remove();
    }
    }]
});

var auto=new Ext.Panel({
	layout: 'accordion',
    renderTo:'grid_<?=$gridId?>',
    items:[link_add,auto_check]
});

});
</script>
<body style="width:98%;height:100%">
<div id='grid_<?=$gridId?>'></div>
</body>
</html>
